package org.springframework.remoting.jsonrpc;

import java.text.DecimalFormat;

import org.jabsorb.serializer.MarshallException;
import org.jabsorb.serializer.SerializerState;

public class PrimitiveSerializer extends
		org.jabsorb.serializer.impl.PrimitiveSerializer {

	public PrimitiveSerializer() {
		super();
	}

	public Object marshall(SerializerState state, Object o, Object b)
			throws MarshallException {
		if (long.class.equals(o.getClass()) || short.class.equals(o.getClass())
				|| int.class.equals(o.getClass())) {
			return new DecimalFormat("#").format(o);
		} else if (float.class.equals(o.getClass())
				|| double.class.equals(o.getClass()))

			return new DecimalFormat("#.#").format(o);

		return super.marshall(state, o, b);
	}
}
